package com.huawei.esdk.tp.domain.model;

import java.util.Date;
import java.util.List;

import com.huawei.esdk.platform.common.SDKResult;
import com.huawei.esdk.platform.common.exception.SDKException;
import com.huawei.esdk.platform.common.utils.ApplicationContextUtil;
import com.huawei.esdk.platform.nemgr.itf.IDeviceManager;
import com.huawei.esdk.tp.common.constants.TPConstant;
import com.huawei.esdk.tp.device.smc.v100r003c10.SMC20V1R3C10IConferenceManagerCapability;
import com.huawei.esdk.tp.domain.model.bean.AdhocConfFreeBusyStateList;
import com.huawei.esdk.tp.domain.model.bean.AdhocConferencesList;
import com.huawei.esdk.tp.domain.model.bean.DateTimeRange;
import com.huawei.esdk.tp.domain.model.bean.PagedList;
import com.huawei.esdk.tp.domain.model.bean.QueryCondition;
import com.huawei.esdk.tp.domain.model.bean.QuerySites;
import com.huawei.esdk.tp.domain.model.bean.SortField;

/**
 * Adhoc会议，以接入码(accessCode)为标识
 * 
 * @author j00160659
 * 
 */
public class AdhocConference
{
    private String accessCode;
    
    private String name;
    
    private List<Conference> singleConf;
    
    private static IDeviceManager deviceManager = (IDeviceManager)ApplicationContextUtil.getBean("deviceManager");
    
    public static IDeviceManager getDeviceManager()
    {
        return deviceManager;
    }
    
    public static void setDeviceManager(IDeviceManager deviceManager)
    {
        AdhocConference.deviceManager = deviceManager;
    }
    
    public String getAccessCode()
    {
        return accessCode;
    }
    
    public void setAccessCode(String accessCode)
    {
        this.accessCode = accessCode;
    }
    
    public String getName()
    {
        return name;
    }
    
    public void setName(String name)
    {
        this.name = name;
    }
    
    public List<Conference> getSingleConf()
    {
        return singleConf;
    }
    
    public void setSingleConf(List<Conference> singleConf)
    {
        this.singleConf = singleConf;
    }
    
    public AdhocConference(String accessCode)
    {
        this.accessCode = accessCode;
    }
    
    //////////////////////////////////////////////////////////////////////////////
    
    /**
     * @param filters
     * @param sortFields
     * @param recordPerPage
     * @param curPageNo
     * @return
     * @see SMC:QueryAdhocConferences
     */
    public static SDKResult<PagedList<AdhocConference>> queryAdhocConference(List<QueryCondition> filters,
        List<SortField> sortFields, int recordCountPerPage, int curPageNo)
    {
        return new SDKResult<PagedList<AdhocConference>>();
    }
    
    /**
     * @param accessCodes
     * @param tmSpan
     * @return
     * @see SMC:QueryAdhocConfFreeBusy
     */
    public static SDKResult<List<AdhocConference>> queryAdhocConfFreeBusy(List<String> accessCodes, DateTimeRange tmSpan)
    {
        return new SDKResult<List<AdhocConference>>();
    }
    
    /**
     * @param accessCodes
     * @param tmSpan
     * @return
     * @see SMC:SynchAdhocConfFreeBusy
     */
    public static SDKResult<List<AdhocConference>> syncAdhocConfFreeBusy(List<String> accessCodes, DateTimeRange tmSpan)
    {
        return new SDKResult<List<AdhocConference>>();
    }
    
    public static SDKResult<AdhocConfFreeBusyStateList> queryAdhocConfFreeBusyEx(Integer duration, Date beginTime,
        List<String> confAccessCodes)
        throws SDKException
    {
        SMC20V1R3C10IConferenceManagerCapability confMgr =
            deviceManager.getDeviceServiceProxy(TPConstant.DEV_ID_SMC, SMC20V1R3C10IConferenceManagerCapability.class);
        return confMgr.queryAdhocConfFreeBusyEx(duration, beginTime, confAccessCodes);
    }
    
    public static SDKResult<AdhocConfFreeBusyStateList> synchAdhocConfFreeBusyEx(Integer duration, Date beginTime,
        List<String> confAccessCodes)
        throws SDKException
    {
        SMC20V1R3C10IConferenceManagerCapability confMgr =
            deviceManager.getDeviceServiceProxy(TPConstant.DEV_ID_SMC, SMC20V1R3C10IConferenceManagerCapability.class);
        return confMgr.synchAdhocConfFreeBusyEx(duration, beginTime, confAccessCodes);
    }
    
    public static SDKResult<AdhocConferencesList> queryAdhocConferencesEx(QuerySites querySites)
        throws SDKException
    {
        SMC20V1R3C10IConferenceManagerCapability confMgr =
            deviceManager.getDeviceServiceProxy(TPConstant.DEV_ID_SMC, SMC20V1R3C10IConferenceManagerCapability.class);
        return confMgr.queryAdhocConferencesEx(querySites);
    }
}
